#include <iostream>
#include <string>
using namespace std;
int n, sum = 0;
int a;
int main()
{
    cin >> a;
    cin >> n;
    int j = 0;
    bool p = false;
    for (int i = 1; i <= a; i++)
    {
        j = i;
        p = false;
        if (n == j % 10)
            sum++;
        if (j < 10)
            p = true;
        while (!p)
        {
            j /= 10;
            if (n == j % 10)
                sum++;
            if (j < 10)
                p = true;
        }
    }
    cout << sum;
}
// 1-10 2
//